home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
tttool30.arc
/
MANUAL.TTT
< prev
next >
Wrap
Text File
|
1987-02-17
|
97KB
|
3,826 lines
TechnoJocks Turbo Toolkit
Version 3.0
Released: October 1, 1986
"In the software business since Tuesday"
CONTENTS
Section 1 INTRODUCTION ............................... 3
Section 2 OTHER GOODIES FOR YOUR TOOLKIT ............. 5
Section 3 HOW THE TOOLKIT WORKS ...................... 7
Section 4 FASTWRIT.TTT ............................... 8
Section 5 WINDOW.TTT ................................. 25
Section 6 MENU.TTT ................................... 31
Section 7 IO.TTT ..................................... 36
Section 8 MISC.TTT ................................... 42
Index List of all Procedures and Functions ....... 55
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 2
Section 1 INTRODUCTION
The Toolkit is a collection of procedures and functions for Turbo
Pascal programmers. It is designed to speed up the time it takes to
write applications and can be a considerable productivity aid,
especially for the less experienced programmer.
The Toolkit evolved from a need to develop procedures and functions
for my own applications. They are not a comprehensive set of
procedures covering the breadth and depth of applications programming.
They concentrate on screen orientated applications for CGA systems ,
to the exclusion of disk IO and printer control. If you are looking
for a more comprehensive library see Section 2.
The TTT (TechnoJocks Turbo Toolkit) disk contains the following files:
Decl.TTT - All the Type, Const and Var declaration required by
the procedures and functions.
FastWrit.TTT - A collection of ultra-fast screen writing procedures
which are all based on an "Inline" screen update
procedure.
Window.TTT - A collection of windowing and screen saving
procedures.
Menu.TTT - A very nice (better than Blaise) menu routine.
IO.TTT - A collection of screen input routines.
Misc.TTT - A host of miscellaneous procedures and functions.
?????TTT.DEM - Demonstration examples in the use of the Toolkit.
?????TTT.com - Compiled versions of the above .DEM files.
README.TTT - Latest Documentation for the Toolkit.
Manual.TTT - This documentation.
Please distribute this Toolkit to fellow Turboholics, the only
distribution conditions are that the code must not be modified or
altered, and that no fee must be charged. Enough crap!
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 3
The quickest way of getting a quick appreciation of the capabilities
of the Toolkit is to execute the program DemoTTT.com. This
demonstrates most of the procedures and functions available. The Demo
itself was, of course, written with the Toolkit. If you haven't run it
yet, run it now!
There are 5 other demonstration programs in the toolkit. They are much
smaller and are designed to simply demonstrate one specific part of
the Toolkit. The source code is provided and are useful illustrations
of the coding simplicity.
The heart of the Toolkit are the files with TTT extensions; they are
the source code for all the procedures and functions.
Finally, TechnoJocks NO NONSENSE LICENSE STATEMENT! If any part of
this package is in any way faulty it's not Technojocks problem,
especially if you screw up big and try to blame me!. If you do find
any problems or bugs (!) or can recommend improvements, let me know.
Bitches, gripes, thanks, kisses, donations (not in that order!) to:
Bob Ainsbury
Technojock
P.O. Box 2197
Houston TX 77252
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 4
Section 2 OTHER GOODIES FOR YOUR TOOLKIT
Over the past twelve months I have scoured the earth for good tools to
help me with applications development in Turbo Pascal. This section
simply details what I think are the best of the crop. The tools range
from shareware/freeware, to individual developers, and on to the
professional development companies.
STAYRES If you ever need to write "terminate and stay resident"
programs then the STAYRES procedures are a must. The
latest version (at press time) is 4.10. The utility is
shareware and is available on the main Turbo Bulletin
Boards (see the end of this section). The utility was
developed by The Hunters Helper Lane Ferris et al. If
you are unable to locate a copy, contact:
Lane Ferris
4268 26th St
San Francisco, Ca. 94131
Compuserv 70357,2716
EXEC This small (but not simple) utility allows you to run
other programs from within a turbo program. It is
straight forward to use and free. The latest version is
1.2. The utility was developed by Bela Lubkin of
Borland International Technical Support.
BOOSTERS George F Smith has developed a comprehensive set of
procedures and functions covering a whole range of
needs. All his utilities are well documented and ULTRA
fast. The are nearly all Inline based and are orintated
to IBM and true compatibles.The latest version is 1.02.
Like the Toolkit, these utilities are screen
orientated, but they include extensive string handling
and an alternative to EXEC (mentioned above). Boosters
is available on the main Turbo Bulletin Boards, but if
you are unable to locate a copy, contact:
George F. Smith
609 Candlewick Lane,
LilBurn, GA 30247
(404) 923-6879
VSCREEN The Vscreen package contains a very powerful array of
window routines (no other package comes close),
together with a comprehensive set of screen IO
routines. The only weakness of the package is that if
you use VScreen utilities, the whole of the application
needs to adopt the VScreen rules, and the code size is
large. Nonetheless it is a good package. A demo version
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 5
is available on the bulletin boards. For further
information, contact:
Northpoint Software
1817 Domanik Drive
Racine, WI 53404
(414) 637-7540
BLAISE There is no doubt in my mind that Blaise Power Tools
Plus is the most comprehensive set of tools for Turbo
Pascal. They are professionally written and very well
documented. The tools cover the breadth and depth of
needs from file IO to memory resident and beyond. There
are two drawbacks. Firstly, a price tag of $99.95.
Secondly, the procedures can be slow to compile because
of the extensive error checking that takes place, and
the deeply nested include file approach. Overall
though, it is a very professional, good quality
product. For further information contact:
Blaise Computing Inc.
2560 Ninth Street
Suite 316
Berkeley, CA 94710
(415) 540-5441
SOURCEPRINT - If you want the best formatted printouts available then
I suggest you put your hand in your pocket and buy
SourcePrint. There is now a friendly screen driven menu
that saves you worrying about all the setup strings,
and the latest version provides a wealth of formatting
options. SourcePrint retails for $139.00 and is
available from:
Alderbaran Laboratories
3339 Vincent Dr.
Pleasant Hill, CA 94523
(800) 257 5773
If you are new to Turbo Pascal, I suggest you buy the Turbo Tutor
version 2.0 from Borland International. If you are not completely
penniless, I also recommend you buy Jeff Duntemann's "Complete Turbo
Pascal". Finally, consider joining TUG; the very well run Turbo Users
Group -- contact TUG, P.O. Box 1510, Poulsbo, WA 98370. As promised,
listed below are some of the bulletin boards which contain Turbo
Pascal goodies:
High Sierra BBS, sysop David Carroll, (209) 296 3534
Computers Unlimited, Chuck Childers, (513) 258 0020
Wilmington Fido, Bob Klahn, (302) 764 7522
Windmill, Duke Stafford, (806) 792 6116
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 6
Section 3 HOW THE TOOLKIT WORKS
Basics -- Turbo Pascal has what is called an include directive {$I}
which allows you to include source code from another file into your
main program. For example, placing the statement {$I
c:\turbo\decl.ttt} in your program will have the same effect as
merging the contents of the file decl.ttt into your program. It
provides a convenient method of maintaining a library of files. The
Toolkit is such a library. All you need to do is decide which
procedures and functions you want to use and include them in your
source code with the {$I filename} directive. Read the Turbo Pascal
v3.0 reference manual page 147 for a full explanation.
All the Toolkit procedures and functions require the file DECL.TTT to
be included first. You then simply include the TTT files which are
required for that particular procedure or function.
The technique is best illustrated with an example. In the file
MISC.TTT there is a function, called Date, which returns the current
date in long form. A somewhat trivial program to write the date on the
screen would be as follows :
Program Toolkit_Example;
{$I Decl.TTT}
{$I Misc.TTT}
begin
Clrscr; {clear the screen}
Write(Date);
end.
In the following sections, we will discuss all the procedures and
functions in the Toolkit, and show examples of their use.
The Appendix contains a list of all the procedures and functions,
together with the appropriate TTT filename.
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 7
Section 4 FASTWRIT.TTT
The Fastwrit.TTT file contains a host of procedures for updating the
screen, together with cursor control procedures. Execute the file
WriteDem.com to see some of the features. Note that these procedures
are machine dependant and will only work on IBM and true compatibles
(the procedures were developed on a Compaq Deskpro 286).
The Fastwrite core procedure is based on the original developed by
Marshall Brain, Troy, New York and published in TUG Lines Issue 9. It
also incorporates Sergio Polini's modifications.
The following procedures are detailed in this section:
Box
HorizLine
VertLine
WriteAT
ClearText
WriteCenter
WriteBetween
WriteVert
TempMessage
FindCursor
PosCursor
SizeCursor
OffCursor
OnCursor
VideoOn
VideoOff
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 8
Section 4 Fastwrit.TTT (cont.)
Procedure BOX
Purpose Draw rectangular box on screen
Syntax Box( X1,Y1,X2,Y2,F,B,Boxtype:integer);
where X1 top left X coordinate (1..80)
Y1 top left Y coordinate (1..25)
X2 lower right X coord. (1..80)
Y2 lower right Y coord. (1..25)
F foreground color (0..15)
B background color (0..7)
Boxtype line thickness (1,2,3,4)
Notes 1) The area inside the rectangle is not cleared
2) The values for Boxtype are:
1 Single line
2 Double line
3 Single top/bottom, double sides
4 Double top/bottom, single sides
If a Boxtype of 0 is passed then the procedure will use
' ' as the box character, any other value will result
in a single line box.
Examples:
{$I Decl.TTT}
{$I Fastwrit.TTT}
begin
Clrscr;
Box(20,1,60,5,yellow,black,2);
Box(1,7,80,25,15,1,1);
end;
The above code fragment would result in two boxes being drawn on the
screen. The top box would be a double yellow lined box on a black
background, and the other larger box would be a white single lined box
on a blue background.
Note: the color codes are available in the Turbo Pascal Reference
Manual V3.0 on page 161.
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 9
Section 4 Fastwrit.TTT (cont.)
Procedure HORIZLINE
Purpose Draw horizontal line on the screen
Syntax HorizLine(X1,X2,Y,F,B,Linetype:integer);
where X1 left X coordinate (1..80)
X2 right X coordinate(1..80)
Y Y coordinate (1..25)
F foreground color (0..15)
B background color (0..7)
LineType line thickness (1,2,3,4)
Notes 1) The values for Linetype are:
1 Single
2 Double
3 Single
4 Double
2) X2 can be larger than X1.
Example:
{$I Decl.TTT}
{$I Fastwrit.TTT}
begin
Clrscr;
HorizLine(20,60,5,lightgreen,green,1);
HorizLine(15,4,24,14,6,4);
end;
The above code fragment would result in two lines being drawn on the
screen. The first line would be a single lightgreen line on a green
background located on line 5 (one fifth of the way down the screen),
starting at position 20 and ending at 60. The second line would draw a
double yellow line on a brown background located on line 24 (next to
last line on screen) between x coords 4 and 15.
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 10
Section 4 Fastwrit.TTT (cont.)
Procedure VERTLINE
Purpose Draw vertical line on the screen
Syntax HorizLine(X,Y1,Y2,F,B,Linetype:integer);
where X X coordinate (1..80)
Y1 top Y coordinate (1..80)
Y2 bottom Y coord (1..25)
F foreground color (0..15)
B background color (0..7)
LineType line thickness (1,2,3,4)
Notes 1) The values for Linetype are:
1 Single
2 Double
3 Single
4 Double
2) X2 can be larger than X1.
Example:
{$I Decl.TTT}
{$I Fastwrit.TTT}
begin
Clrscr;
Vertline(1,1,25,white,black,1);
VertLine(80,25,1,15,0,3);
end;
The above code fragment will draw two vertical white lines on the left
and right extremes of the screen. Note that the second statement has
the Y coords in reverse order - the procedure will still function
correctly.
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 11
Section 4 Fastwrit.TTT (cont.)
Procedure WRITEAT
Purpose Writes directly to the screen el quicko
Syntax WriteAT(X,Y,F,B:integer;ST:string80);
where X X coord of first char in string (1..80)
Y Y coord of string (1..25)
F foreground color (0..15)
B background color (0..7)
ST text string (up to 80 chars in length)
Notes 1) This procedure cannot be used to write integers/reals
2) You may pass concatenated strings (see code fragment)
3) X,Y coords outside the accepted range will result in
the text being wrapped to the next line.
Example:
{$I Decl.TTT}
{$I Fastwrit.TTT}
Const Heading = 'Toolkit';
begin
Clrscr;
WriteAT(1,25,yellow,red,'Press F1 for help');
WriteAT(25,1,green,black,heading);
WriteAT(60,13,1,0,'Technojocks Turbo '+heading);
end;
The above code fragment illustrates a number of different ways of
writing directly to the screen. The first statement simply writes the
help message at the bottom of the screen. The second line writes the
string constant TOOLKIT part way along the first line, and finally the
last statement would write 'Technojocks Turbo Toolkit' on the end of
the 13 th. line.
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 12
Section 4 Fastwrit.TTT (cont.)
Procedure CLEARTEXT
Purpose To clear part or all of the screen
Syntax ClearText(X1,Y1,X2,Y2,F,B:integer);
where X1 top left X coordinate (1..80)
Y1 top left Y coordinate (1..25)
X2 lower right X coord (1..80)
Y2 lower right Y coord (1..25)
F foreground color (0..15)
B background color (0..7)
Notes 1) This is preferred to the Turbo Pascal procedure Clrscr
in situations where the window procedure is in effect -
it will clear the defined area regardless of the window
setting.
2) The procedure is used extensively in the TTT Window and
Menu routines.
3) The foreground color sets the foreground attribute but
does not affect the display immediately.
Example
{$I Decl.TTT}
{$I Fastwrit.TTT}
begin
ClearText(1,1,40,25,0,green);
ClearText(41,1,80,25,0,red);
end;
The above code fragment will clear the full screen, coloring the left
half green and the right half red.
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 13
Section 4 Fastwrit.TTT (cont.)
Procedure WRITECENTER
Purpose To write text on the center of a line
Syntax WriteCenter(LineNo,F,B:integer;ST:string80);
where LineNo the Y coord or line number
(1..25)
F foreground color
(1..15)
B background color
(0..7)
ST text string (up to 80 chars in
length)
Notes 1) The same rules apply as for WriteAT i.e. no
reals/integers,
strings may be concatenated,no checking on Y validity.
Example
{$I Decl.TTT}
{$I Fastwrit.TTT}
begin
Clrscr;
WriteCenter(1,white,green,'Company Title');
WriteCenter(2,white,green,'Kato '+'Catering Company');
end;
The above code fragment simply centers two headings on the top two
lines of the screen in white on a green background.
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 14
Section 4 Fastwrit.TTT (cont.)
Procedure WRITEBETWEEN
Purpose To write text centered between two points
Syntax WriteBetween(X1,X2,Y,F,B:integer;ST:string80);
where X1 left X coordinate (1..80)
X2 right X coordinate (1..80)
Y the Y coord or line no (1..25)
F foreground color (0..15)
B background color (0..7)
ST text string (up to 80 chars in length)
Notes 1) If the length of the string is greater than the
distance between the X coordinates, the string will
simply be written commencing at X1.
Example
{$I Decl.TTT}
{$I Fastwrit.TTT}
Begin
Clrscr;
WriteBetween(35,70,5,green,blue,'Middle');
WriteBetween(1,80,1,white,black,'Same effect as WriteCenter');
end;
The above code fragment would write two lines of text to the screen.
The first would write Middle on the fifth line centered between points
35 and 75. Note the second command would have the same effect as
WriteCenter.
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 15
Section 4 Fastwrit.TTT (cont.)
Procedure WRITEVERT
Purpose To write text vertically on the screen
Syntax WriteVert(X,Y,F,B:integer;ST:string80);
where X X coord of first char in string (1..80)
Y Y coord of first char in string (1..25)
F foreground color (0..15)
B background color (0..7)
ST text string ( up to 25 chars in length)
Example
{$I Decl.TTT}
{$I Fastwrit.TTT}
begin
Clrscr;
WriteVert(40,1,red,black,'This is the middle');
end;
The above code fragment will simply write the text This is the middle
down the center of the screen.
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 16
Section 4 Fastwrit.TTT (cont.)
Procedure TEMPMESSAGE
Purpose To display a message anywhere on the screen, wait
for a keypress, and then restore the original
screen contents.
Syntax TempMessage(X,Y,F,B:integer;ST:string80);
where X the X coord of the first char (1..80)
Y the Y coord or the first char (1..25)
F foreground color (0..15)
B background color (0..7)
ST text string (up to 80 chars in length)
Notes 1) The procedure temporarily stores the line of text
together with its attributes, displays the tempoary
message, and after a key is pressed (any key), the
original text and attributes are returned to the
screen.
2) The procedure is most useful when the screen is very
'busy' and you want to display an error or warning
message.
3) The keyboard buffer is cleared so the keypress is not
passed back to the calling procedure i.e. you are
unable to determine which key was pressed.
Example
{$I Decl.TTT}
{$I Fastwrit.TTT}
begin
TempMessage(1,25,yellow,red,'Unable to find file');
end;
The above code fragment will display the message Unable to find file
until the user presses a key.
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 17
Section 4 Fastwrit.TTT (cont.)
Procedure FINDCURSOR
Purpose Returns the location and size of the cursor
Syntax FindCursor(var X,Y,ScanTop,ScanBot:integer);
where X the X coord of the cursor (1..80)
Y the Y coord of the cursor (1..25)
ScanTop the top scan code (0..13)
ScanBot the bottom scan code (1..13)
Notes 1) You must pass 4 variables to this procedure and they
will be returned with the current cursor settings.
2) The scan codes refer to the actual location of the top
and bottom of the cursor within a given character
field, where zero is the top of the field (as is the
top stroke of the letter T -- got it?), and either 13
or 7 is the bottom of the field on monochrome or color
systems respectively. On a color system a ScanTop of 6
and a ScanBot of 7 would indicate the normal DOS type
cursor, or 4/7 would be a half block cursor. For more
information refer to the Peter Norton book 'Inside The
IBM PC'.
3) The procedure is preferable to the Turbo Pascal
functions WhereX and WhereY because the results are not
affected by the Window paramaters in effect (as well as
returning the cursor size!).
Example
{$I Decl.TTT}
{$I Fastwrite.TTT}
Var LocX,LocY,Upper,Lower : integer;
begin
FindCursor(LocX,LocY,Upper,Lower);
If (LocX in [1..40]) and (LocY in [1..15]) then ......
end;
In the above code fragment the values returned in the variables are
the Cursor details which can subsequently be acted upon. In this case
an if statement checks to see if the cursor is in the left half of the
screen betwwen lines 1 and 15. See procedure SizeCursor for another
example.
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 18
Section 4 Fastwrit.TTT (cont.)
Procedure POSCURSOR
Purpose To relocate the cursor to any loaction on the
screen
Syntax PosCursor(X,Y:integer);
where X the X coordinate of the cursor (1..80)
Y the Y coordinate of the cursor (1..25)
Notes 1) This procedure is preferable to Turbo Pascal's GotoXY
statement when window settings are to be ignored.
Example
{$I Decl.TTT}
{$I Fastwrit.TTT}
begin
PosCursor(25,80);
end;
This simple code fragment locates the cursor at the bottom right of
the screen. See the next procedure SizeCursor for an additional
example.
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 19
Section 4 Fastwrit.TTT (cont.)
Procedure SIZECURSOR
Purpose To change the shape/appearance of the cursor
Syntax SizeCursor(Scantop,ScanBot:integer);
where ScanTop is the top scan line (0..14)
ScanBot is the bot scan line (0..13)
Notes 1) Refer to the procedure FindCursor for a discussion on
scan codes.
2) Note that setting the top scan code will result in a
'hidden' cursor on both monochrome and color systems.
Example
{$I Decl.TTT}
{$I Fastwrit.TTT}
var PosX,PosY,Top,Bot : integer;
begin
FindCursor(PosX,PosY,Top,Bot);
Help_System; {say, a procedure that changes the
cursor}
PosCursor(PosX,PosY);
SizeCursor(Top,Bot);
end;
The above code fragment will determine the cursor characteristics with
the FindCursor procedure. Another unrelated procedure is then called,
in this example Help_System. When the Help_System procedure is
finished, the cursor position and size is returned to its original
state with the PosCursor and SizeCursor procedures.
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 20
Section 4 Fastwrit.TTT (cont.)
Procedure OFFCURSOR
Purpose A quick method of switching the cursor off
Syntax OffCursor;
Notes 1) The procedure hides the cursor on monochrome and
color systems.
Example
{$I Decl.TTT}
{$I FastWrit.TTT}
begin
OffCursor;
end;
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 21
Section 4 Fastwrit.TTT (cont.)
Procedure ONCURSOR
Purpose A quick way of setting the cursor to the DOS
default
Syntax OnCursor;
Notes The procedure checks to see if the system is monochrome
or color and sets the cursor to an underline;
Example
{$I Decl.TTT}
{$I Fastwrit.TTT}
begin
OnCursor;
end;
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 22
Section 4 Fastwrit.TTT (cont.)
Procedure VIDEOOFF
Purpose Switches off the video port to avoid CGA snow
Syntax VideoOff;
Notes 1) Snow occurs on systems fitted with a Color
Graphics Adapter when direct writes to video
memory are performed. The Fastwrit procedures are
designed to minimize snow but in extreme cases you
may want to specifically switch off (or freeze)
the display while the update is undertaken -- the
screen can then be refreshed by issuing the
VideoOn command (see next procedure).
2) In the Decl.TTT file there is a boolean variable
called SNOW which is set to False. If you want to
automatically alter the main screen updating
procedures simply set snow to TRUE and the TTT
procedures will invoke VideoOff and VideoOn as
necessary on large screen writes (see Window.TTT).
Example
{$I Decl.TTT}
{$I Fastwrit.TTT}
var I,J : integer;
begin
VideoOff;
For I := 1 to 80 do
For J := 1 to 25 do
WriteAT(I,J,white,black,'$');
VideoOn;
end;
The above code fragment freezes the screen with the VideoOff command,
writes a $ sign at every location on the screen, and then refreshes
the screen with the VideoOn command;
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 23
Section 4 Fastwrit.TTT (cont.)
Procedure VIDEOON
Purpose To switch the video on following VideoOff
Syntax VideoOn;
Notes 1) Refer to the previous procedure VideoOff;
Example
{$I Decl.TTT}
{$I Fastwrit.TTT}
var I,J : integer;
begin
VideoOff;
For I := 1 to 80 do
For J := 1 to 25 do
WriteAT(I,J,white,black,'$');
VideoOn;
end;
The above code fragment freezes the screen with the VideoOff command,
writes a $ sign at every location on the screen, and then refreshes
the screen with the VideoOn command.
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 24
Section 5 WINDOW.TTT
The Window.TTT files contains both windowing and screen saving
procedures.
The Window routines allow you to construct windows with specified
colors, border size and style. A window overlays all or part of the
screen, but both the screen and the cursor details are saved with the
screen. When the window is removed the original screen contents are
restored and the cursor is repositioned as necessary. The window
routines are for text mode only and use BIOS calls which are IBM (or
close compatible) specific. Windows can be layered on top of each
other as deeply as the system can handle, approximately 100 (if you
are silly enough).
The screen saving procedures allow you to save a screen on the heap
(so the 64k data limit is not eaten up by saved screens) and
subsequently restore them from the heap in an instant. There are also
features to avoid snow on CGA machines.
To conserve space the maximum number of saved screens is arbitrarily
set to 4 and the number of saved windows is set to 4. These maximums
can be readily modified without any impairment in response or
efficiency. There are two constants in the Decl.TTT file :
Max_WindowsandScreens, and Max_Screens -- just adjust them as
necessary.
Execute the files SavedDem.com and WindoDem.com to see some of these
features in action.
Note that both Decl.TTT and Fastwrit.TTT must be included before
Window.TTT -- window utilizes some of the procedures in Fastwrit.TTT.
The following procedures are detailed in this section:
SaveScreen
RestoreScreen
DisposeScreen
MkWin
RmWin
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 25
Section 5 Window.TTT (cont.)
Procedure SAVESCREEN
Purpose To Save the screen image on the Heap
Syntax SaveScreen(Page:byte);
where Page is a unique page number
Notes 1) This procedure will save a full copy of the screen and
all the attributes (color etc.). The location of the
cursor is also saved.
2) It is good practice to use page numbers starting with
1, but make sure there is not another page on the heap
saved under the same number (see procedure
DisposeScreen) otherwise it will be overwritten.
Example
{$I Decl.TTT}
{$I Fastwrit.TTT}
{$I Window.TTT}
begin
Savescreen(1);
end;
See the procedure DisposeScreen for a more meaningful example of
SaveScreen.
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 26
Section 5 Window.TTT (cont.)
Procedure RESTORESCREEN
Purpose To restore a previously saved screen
Syntax RestoreScreen(Page:byte);
where Page is the same number that was specified with
the corresponding SaveScreen.
Notes 1) Only use the page number that was specified with a
previous SaveScreen, otherwise unpredictable results
will occur (e.g. the flashing happy faces).
2) The restore screen will return the cursor to the
position it was in immediately prior to the SaveScreen.
3) If the program is to run on a snowy graphics adapter
then simply set the boolean constant to TRUE prior to
the restore, and if prudent, set it back to false
afterwards. See procedure VideOff in Section 4 for a
further explanation of snow.
Example
{$I Decl.TTT}
{$I Fastwrit.TTT}
{$I Window.TTT}
begin
RestoreScreen(1);
end;
See the procedure DisposeScreen for a more meaningful example of
RestoreScreen.
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 27
Section 5 Window.TTT (cont.)
Procedure DISPOSESCREEN
Purpose To clear a saved screen from the heap.
Syntax DisposeScreen(Page:byte);
where Page is the number of a screen saved with
SaveScreen.
Notes 1) If you have restored a screen using RestoreScreen and
you no longer need the saved screen image, use this
procedure to trash the image and release the heapspace
for use by other procedures.
2) The SaveScreen and DisposeScreen procedures use the
standard Turbo Pascal New/Dispose heap control
procedures. These should not be mixed in a program that
uses the exclusive alternative of Mark/Release.
Example
{$I Decl.TTT}
{$I Fastwrit.TTT}
{$I Window.TTT}
begin
Savescreen(1);
OffCursor;
HelpProcedure; { any procedure which modifies the screen display }
RestoreScreen(1);
DisposeScreen(1);
End;
This code fragment illustrates a typical application for the TTT
screen management procedures. Firstly the screen is saved in page 1,
then the cursor is switched off, and another procedure is called which
modifies all or part of the screen -- in this example, HelpProcedure.
After the help procedure is finished, the original screen and cursor
location are restored. Finally the saved screen, which is no longer
required, is discarded with the DisposeScreen(1) statement.
Note that the next screen could also be saved to page 1 because the
original page 1 is now disposed of.
Another application is to save menu screens after their first display
so that they can be instantly restored at any stage in the program.
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 28
Section 5 Window.TTT (cont.)
Procedure MKWIN
Purpose To overlay a rectangular window on the screen
Syntax MkWin(X1,Y1,X2,Y2,F,B,boxtype:integer);
where X1 top left X coordinate (1..80)
Y1 top left Y coordinate (1..25)
X2 lower right X coord (1..80)
Y2 lower right Y coord (1..25)
F foreground color (0..15)
B background color (0..7)
Notes 1) The specifications are the same as for the Box
procedure in Fastwrit.TTT i.e. Boxtype
1 Single line
2 Double line
3 Single top/bottom, double sides
4 Double top/bottom, single sides
A 0 boxtype will result in no box being drawn, any
other value will result in a single line box.
2) Windows can be nested and overlapping but they must be
removed in the same order they were displayed.
3) The window procedures use the screen saving procedures
discussed previously.
4) The window inside the border is cleared to the
background color.
5) The standard Turbo Pascal procedure Window is not set,
primarily because I do not use it. If you want to set
the Window coordinates simply issue a Window statement
following the MkWin procedure.
Example
See RmWin for an example of the TTT Window procedures.
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 29
Section 5 Window.TTT (cont.)
Procedure RMWIN
Purpose To remove a window and restore the original screen
Syntax RmWin;
Notes 1) The RmWin procedure removes the last displayed window.
Successive RmWin statements will remove the earlier
displayed window. If Rmwin is called when there are no
windows, the procedure simply returns i.e. no problem.
2) The procedure utilises RestoreScreen and DisposeScreen
discussed previously.
Example
{$I Decl.TTT}
{$I Fastwrit.TTT}
{$I Window.TTT}
begin
MkWin(25,20,65,25,white,red,1);
WriteBetween(25,65,23,white,red,'Are you sure you want to exit?');
Read(Kbd,Ch);
If upcase(Ch) = 'Y' then
Halt
else
RmWin;
end;
The above code fragment paints a red window with a white single line
border on the last five lines of the screen, and displays a message in
the center of the box. If the user responds Y then the program
terminates, otherwise the window is removed and the program continues.
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 30
Section 6 MENU.TTT
The Menu Kit is probably the most useful and intelligent
(artificially!) Kit in the whole package. The best way of gaining a
quick appreciation of the capabilities of the menu procedure is to
execute the DemoTTT.com file. If you haven't done so already, run it
now.
The menus generated are flexible in format. However the menus are all
of the move-the-cursor and highlight-the-options style.
All you have to do is define a record which contains the menu format
details and call the procedure DISPLAYMENU. The Toolkit does the rest
and returns the chosen option.
All you have to understand is the menu record. The format of the
record is defined in Decl.TTT as follows:
Menu_record = record
Heading : string80;
Text : array[1..Max_choices] of string80;
TotalPicks : integer;
PicksPerLine : byte;
AddPrefix : byte;
TopLeftXY : array[1..2] of byte;
BoxType : byte;
Colors : array[1..5] of byte;
AllowEsc : boolean;
end;
In the examples that follow, it is assumed that a variable M of type
menu_record has been defined e.g. Var M : Menu_record;
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 31
Section 6 Menu.TTT (cont.)
Heading If you want to have a heading at the top of the menu
then this is where you specify it e.g.
M.Heading = 'The Main Menu';
If you do not want a heading then define it as a nul
string e.g. M.Heading = '';
Text This is the array of the actual menu prompts that will
be displayed in the menu. If there are 4 choices on the
menu then the declaration might be:
M.Text[1] := 'View Reports on Screen';
M.Text[2] := 'Send Reports to a Print File';
M.Text[3] := 'Print the Reports';
M.Text[4] := 'Quit';
TotalPicks Simply declare the total number of menu choices there
are e.g.
M.TotalPicks := 4;
PicksPerLine Declare how many options you want to display on one
line of the screen e.g.
M.PicksPerLine := 1;
AddPrefix The Menu Kit will, if required, automatically prefix
the options with Numbers, Letters or Function Keys. If
you do not want an option prefix then declare the
AddPrefix code as 0 e.g.
M.AddPrefix := 0;
The other valid settings are 1,2, or 3. These function
as follows :
M.AddPrefix := 1; -- this would cause the system to
prefix all the options with a single digit NUMBER. If
there are more than 9 options defined, the system will
prefix with a Alpha instead.
M.AddPrefix := 2; -- this would cause the system to
prefix all the options with ALPHAS starting at A. If
there are more than 26 options defined, the system will
ignore the declaration and set AddPrefix to 0.
M.AddPrefix := 3; -- this would cause the system to
prefix all the options with FUNCTION KEYS starting with
F1. If there are more than 10 options defined the
system will prefix with an Alpha instead.
When a non zero Prefix is operative the user simply has
to press the prefix of the desired option e.g. K or F5.
Alternatively they can move the cursor to highlight the
option and press enter.
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 32
Section 6 Menu.TTT (cont.)
TopleftXY This two byte array holds the X and Y coordinate for
the topleft corner of the menu. That's correct, you
only specify the topleft corner and the system will
calculate all the other dimensions. If you specify
coordinates for the topleft corner too close to the
screen edge, the system will automatically adjust the
coords in order to fully display the menu as close to
those coords as possible. If you set the X coord to 0
the system will automatically center the menu on the
screen. Assuming we want the menu to be displayed in
the center of the screen starting on the 7th line, the
declaration would be :
M.TopleftXY[1] := 0; {X coord}
M.TopLeftXY[2] := 7; {Y coord}
BoxType The boxtype is used to tell the system what type of box
around the menu. The settings are as follows:
0 No box
1 Single line box
2 Double line box
3 Single top/bottom double sides
4 Double top/bottom single sides
If we wanted a single line box around our menu then the
declaration would be :
M.Boxtype := 1;
Colors This is a 5 byte array defining all the colors to use.
Color 1 is the foreground color of the highlighted pick
Color 2 is the background color of the highlighted pick
Color 3 is the normal foreground color
Color 4 is the normal background color
Color 5 is the foreground color of the box
e.g. M.Colors[1] := white;
M.Colors[2] := red;
M.Colors[3] := lightred;
M.Colors[4] := black;
M.Colors[5] := yellow;
AllowEsc The final part of the record is a boolean variable used
to indicate if the Esc key is operative i.e. can the
user escape from the menu? If it is set to false, the
Esc key is ignored. If it is set to true and the user
escapes, a Retcode is set to 99 (discussed later).In
our menu we do not want to allow the user to escape so
the declaration would be:
M.AllowEsc := false;
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 33
Section 6 Menu.TTT (cont.)
Once you have defined a menu record in the format described above, all
you have to do is call the DISPLAYMENU procedure. 4 parameters have to
be passed to the procedure as follows:
The first parameter is the name of the menu_record variable e.g. M.
The second parameter is a boolean (i.e. True or False) to indicate if
the menu is to be displayed on a pulldown window. If this is True,
after the user has chosen an option from the menu, the menu is removed
and the original screen is restored. If it is set to false, the menu
overwrites whatever was in that location on the screen.
The third parameter is an integer variable that is returned to the
calling procedure with the number of the selected option. The initial
value of this parameter indicates which option to first highlight. For
example, if we declared Pick to be an integer variable and set it to
4, then the option highlighted on the menu would be the fourth one.
After the user has selected an option the value of Pick will be the
chosen option. You can then test on Pick and branch the program
accordingly.
The fourth and final parameter is an integer variable that is returned
to the calling procedure with a value of 99 if the user escaped
(assuming AllowEsc is set to true), otherwise it is set to 0.
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 34
Section 6 Menu.TTT (cont.)
That's it, finally an example procedure based on the above
information:
Procedure My_Menu;
var
M : menu_record;
Pick,Retcode : integer;
begin
With M do
begin
Heading := 'The Main Menu';
Text[1] := 'View Reports on Screen';
Text[2] := 'Send Reports to a Print File';
Text[3] := 'Print the Reports';
Text[4] := 'Quit':
TotalPicks := 4;
PicksPerLine := 1;
AddPrefix := 3;
TopleftXY[1] := 0;
TopleftXY[2] := 7;
BoxType := 1;
Colors[1] := white;
Colors[2] := red;
Colors[3] := lightred;
Colors[4] := black;
Colors[5] := yellow;
AllowEsc := false;
end; { with M}
Pick := 4 ; {default to Quit}
DisplayMenu(M,false,Pick,Retcode); {go do it!}
Clrscr;
Case Pick of
1 : writeln('You chose 1');
2 : writeln('You chose 2');
3 : writeln('You chose 3');
4 : writeln('You chose 4');
end; {case}
end; {procedure My_menu}
It's not too bad, is it? Incidentally, this example is in the
demonstration file MenuTTT.Dem and is executable in MenuTTT.com.
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 35
Section 7 IO.TTT
The IO kit is used when you want to allow the user to enter one or
more fields of information on the screen, providing them with the
capability of editing (i.e. inserting, deleting etc) the data. If you
haven't done so already, execute the DemoTTT.com file and select the
IO option. A separate, smaller, demo is in the IOTTT.dem and IOTTT.com
files.
Some of the features of the IO kit include:
* Multiple input fields on each screen
* Optional descriptive messages displayed when editing a field
* Ability to call an independant help procedure
* Optional disabling of the Esc key
* Programmer defined editing keys
In total there are ten procedures which control the IO process, but
before we address them individually lets consider some of the basic
principles.
FORMATTING
When you define an input field (discussed later) you can also specify
the format of the input data. For example, you can define the field to
be numeric and IO will only allow numeric input. The way you define
the format of the input is via pre-defined formatting characters.
There are four such format characters:
# Only 0 to 9 and the '.' decimal point are allowed
@ Only letters of the alphabet and punctuation are allowed
* Anything goes!
! All letters are converted to upper-case
Any other characters are treated as fixed and for display only. For
example, if the input field is a telephone number, then the format can
be defined as '(###) ###-####' . The user will then only be able to
input numbers and, after typing the first three numbers, the cursor
will jump three positions to the right i.e. to the next # character.
Note that all user input data is treated as string data. The string
returned by the IO procedures does not include the non-standard
formatting characters. In the above example the string returned would
be nine numbers i.e. no parentheses or spaces. If you you want to get
an integer from the user then you firstly use the format characters to
control the input, you must then convert the returned string to an
integer (or real or boolean, as necessary) using the standard Turbo
Pascal string manipulation procedures and functions. [Or preferably
using the procedures in the Misc.TTT kit!]
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 36
Section 7 IO.TTT (cont.)
EDITING
In-built within the IO kit are standard editing features which are not
available with the plain old READ(kbd) procedure. The editing keys are
as follows:
CursorUp - the cursor moves 'up' to the previous input field (note
that you define what the previous input field is --
discussed later).
CursorDown - the cursor moves 'down' to the next input field
Ctrl-CursorLeft - the cursor moves 'left' to the previous input field
Ctrl-CursorRight - the cursor moves 'right' to the next input field
CursorRight - the cursor moves to the next character to the right in
the same input field. If it is already one character
past the last typed character it will not move.
CursorLeft - the cursor moves left one character in the same input
field. If the cursor is in position one it will not
move.
Del - deletes the character at the cursor. If there are any
non-standard formatting characters (e.g. parentheses in
the telephone number example) then the deleted
character is replaced with a space, otherwise all
characters to the right are shifted left on position.
Backspace - same as Del except the character to the left of the
cursor is affected.
Tab - move the cursor to the next input field to the 'right',
same as Ctrl-CursorRight.
Shift-Tab - move the cursor to the previous input field to the
'left', same as Ctrl-CursorLeft.
F1 - invoke a help procedure if one has been defined.
Ins - toggles between insert and overlay mode. The cursor is
expanded to half a character in depth when the insert
mode is on.
Esc - end the edit session, if the escape facility is
enabled.
Enter - move the cursor to the next input field to the 'right'.
End - end the input session and proceed with the program.
Note that all these keys are defined in the Decl.TTT file and you can
modify them to meet your own needs and preferences.
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 37
Section 7 IO.TTT (cont.)
Of the ten procedures in the IO kit there are 6 optional procedures
and 4 mandatory procedures. Let us consider the 4 mandatory procedures
first.
IO_Setfields
This procedure must be the first IO procedure and you simply pass the
total number of input fields that will be defined. For example,
IO_Setfields(5) advises the system that 5 input fields will be defined
on the next input screen. Note that this procedure allocates
sufficient space on the heap for the input field details and must
therefore be called before all the other IO procedures.
IO_DefineStr
This is the workhorse procedure where you define all the
characteristics of the input fields. A basic principle of the IO
procedures is that each input field has an ID number and this is a key
element of this procedure. The syntax is as follows :
IO_DefineStr(ID,
U,D,L,R,
X,Y: byte;
var DefString : string80;
DefFormat : string80);
Where:
ID is the aforementioned ID number for this input field. It is logical
(but not mandatory) to start with ID number 1 and increment by one as
you define each field.
U,D,L,R are four bytes which represent the ID's of the fields which
the cursor should move to if the up, down, left or right edit keys are
pressed, respectively. For example, 5,2,5,2 would state that if
the up or left keys are pressed, the cursor will move to field ID 5,
and if the down or right keys are pressed the cursor will move to
field ID 2. Got it? Note that these entries are not validated and it
is up to you to make sure the entries are sensible e.g. don't put ID 6
as the down field if there are only 5 fields in total. One exception
is that an ID of zero (0) indicates that the input session will
terminate (as if the End key had been pressed). This is a useful tool
if you want to end a session after the last field has been updated and
the user tries to move forward to the next input field.
X,Y simply represent the X and Y coordinates of the first character in
the input field. This is how you tell the system the location of the
field on the screen.
DefString is a previously declared parameter of type string80 which is
returned from the IO procedure with the user's input. If you want to
provide the user with a default entry then set the value of DefString
to the required default string, otherwise set it to null i.e. ''.
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 38
Section 7 IO.TTT (cont.)
The final parameter is DefFormat which is the format of the input
field (as discussed previously under the sub-heading FORMATTING).
Phew! Well it is the main procedure. Note that there must be one
DefString statement for each of the input fields as defined in
IO_SetFields.
IO_Edit
When you have declared all the parameters and defined all the IO
procedures (including any optional procedures such as color changes)
then you're ready to let the user input and update the fields. IO_Edit
does this and passes control to the user. The procedure returns
control to your program when the user has ended the update session; by
pressing End or Esc (if it is enabled) or by pressing any of the move
to next field keys (Enter, Tab, etc.) when the next field has been
defined as ID zero. When the IO_Edit procedure is called you must pass
an integer variable. This variable is updated with a return code for
the edit session. The return codes are : 0 for successful completion;
1 if user pressed Esc key 1; 2 if user pressed the alternate Esc key
(if defined).
IO_ResetFields
This procedure is normally the next statement after IO_Edit. It
discards all the field definitions from the Heap and sets all the
optional settings (such as color) back to the default values.
Well, those are the four mandatory procedures. You can repeat the
definitions and procedures as often as you like in a program to
provide multiple screen input. Discussed below are those optional
procedures which you can use to alter the default settings:
IO_AllowEsc(OK:boolean);
This procedure is used to indicate whether the Esc key is disabled or
enabled. The default is Esc disabled but if you want to enable the Esc
key, simply include the following statement : IO_AllowEsc(True);.
IO_SoundBeeper(OK:boolean);
This procedure is used to switch on or off the (annoying) beep that
sounds when the user presses an invalid key. The default is On but if
you want to silence the bugger, include the following statement :
IO_SoundBeeper(False);.
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 39
Section 7 IO.TTT (cont.)
IO_SetColors(HiFore,HiBack,LoFore,LoBack,MsgFore,MsgBack:byte);
Believe it or not, some people don't like my choice of colors. This
procedure is used to set the colors to your preferred values. Note
that the background colors should be in the range 0 to 7 (black to
lightgray) to avoid the retarded IBM flashing effect.
IO_DisplayFields;
Normally the fields are not displayed on the screen until the IO_Edit
procedure is called. But if you want to display the input fields
before allowing the user to edit them then the include the statement
IO_DisplayFields; . This is useful when you want to display the fields
while placing some initial instructions in a window bfore freeing the
user to update.
IO_DefineMsg(DefID, DefX, DefY : byte;Defstring : string80);
You can display a message when the user moves to any input field. When
the user exits the field the message is removed and the original
screen contents (that were overlayed by the message) is restored. You
can define unique messages for one, some or all the input fields. The
parameters of this procedure are used to indicate the field ID to
which the message is to be attached, the X and Y coordinates of the
start of the message, and the message string itself, respectively.
IO_HelpProc(location : integer);
This procedure allows you to pass the address or location of a help
procedure that will be called when the help key is pressed. Before
calling this procedure you must have already declared and defined the
help procedure that you want to be called. Also the procedure must be
declared at the root level of the program -- it must not be nested
within another procedure. The simplest way of passing the location is
to use the Turbo Pascal ofs function. For example, lets say you have
written a help procedure called Instructions, you would then include
the statement IO_HelpProc(ofs(Instructions)); .
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 40
Section 7 IO.TTT (cont.)
Well, that's enough theory. The IO kit is extensive and the
documentation is commensurately long. Nonetheless the kit is designed
to be easy to use and most of the defaults are acceptable (nay,
wonderful). Just remember that you must call the 4 mandatory
procedures as follows:
IO_Setfields
IO_DefineStr
IO_Edit
IO_Resetfields
The best way to become familiar with the IO kit is to look at, and
write, small examples. Refer back to the file IOTTT.dem and see if you
understand it.
The following simple program illustrates an input screen for
requesting the user's name, age and phone number.
Program Find_A_Date;
{$I Decl.TTT}
{$I Fastwrit.TTT}
{$I Misc.TTT}
{$I IO.TTT}
const
Name,
Age,
Phone : string80 = '';
var
Code : integer;
begin
IO_SetFields(3);
IO_SoundBeeper(False);
IO_AllowEsc(true);
IO_DefineStr(1, 3,2,3,2, 35,10, Name, '!!!!!!!!!!!!!!!!');
IO_DefineStr(2, 1,3,1,3, 35,12, Age, '##');
IO_DefineStr(3, 2,1,2,1, 35,14, Phone,'(###) ###-####');
Clrscr;
WriteAT(28,10,yellow,black,'NAME:');
WriteAT(28,12,yellow,black,'AGE:');
WriteAT(28,14,yellow,black,'PHONE:');
IO_Edit(code);
IO_ResetFields;
End.
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 41
Section 8 MISC.TTT
The Misc.TTT kit contains a pot pourri of procedures and functions
which either do not obviously fit in any of the other kits, or are
used by two or more of the kits. I have restricted the size of this
file in order to reduce the compile time. This file is constantly
being modified and improved, but at the time of going to press, the
following procedures and functions were available:
Beep
Printscreen
Wait_for_Keypress
FlushKeyBuffer
Replicate
Int_to_Str
Real_to_Str
Printer_Ready
Time
Date
MemAvail_in_Bytes
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 42
Section 8 Misc.TTT (cont.)
Procedure BEEP
Purpose To emit a short alarm from the speaker
Syntax Beep;
Example:
{$I Decl.TTT}
{$I Misc.TTT}
begin
If not (Choice in ['Q','1'..'5']) then Beep;
end;
The above code fragment will result in a beep if the value of Choice
is not Q or a number in the range 1 to 5.
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 43
Section 8 Misc.TTT (cont.)
Procedure PRINTSCREEN
Purpose To send a copy of text screen to printer
Syntax PrintScreen;
Notes 1) This procedures emulates the PrtSc key on the keyboard
Example:
{$I Decl.TTT}
{$I Misc.TTT}
begin
If Answer = 'Y' then Printscreen;
end;
The above code fragment simply dumps the screen image to the printer
if the value of Answer is Y.
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 44
Section 8 Misc.TTT (cont.)
Procedure WAIT_FOR_KEYPRESS
Purpose To pause a program for user to press a key
Syntax Wait_For_Keypress(var Ch:char);
where Ch is a character variable
Notes 1) The procedure updates the value of Ch with the key that
was pressed. If the key was extended (e.g. the function
keys) then the extended scan code is returned and the
global boolean variable Funckey is set to true.
Example:
{$I Decl.TTT}
{$I Misc.TTT}
var Answer : char;
begin
Wait_For_Keypress(Answer);
If Funckey = true then
Case upcase(Answer) of
F1 : Help;
F2 : AddData;
F3 : DelData;
F4 : ChaData;
F5 : Quit;
else Beep;
end; {case}
end;
The above code fragment represents part of a menu system. The system
pauses for the user to press a key. If a function key is pressed and
it is in the range 1 to 5 then another procedure is called, otherwise
the system beeps.
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 45
Section 8 Misc.TTT (cont.)
Procedure FLUSHKEYBUFFER
Purpose To remove any keystrokes from the keyboard buffer
Syntax FlushKeyBuffer;
Example:
{$I Decl.TTT}
{$I Misc.TTT}
var Answer : char;
begin
Write('Are you sure you want to delete the record? (Y/N)');
FlushKeyBuffer;
Wait_For_KeyPress(Answer);
If (Funckey = false) and (upcase(Answer) = 'Y') then DelRecord;
end;
The above code fragment illustrates the most common use of the
FlushKeyBuffer procedure. The procedure prompts the user for a
response e.g. do they really want to delete the record? The
FlushKeyBuffer procedure is then called to dispose of any surplus
keystrokes that may be held in the keyboard buffer. Then the system
pauses for a user response, and if they answer Y then then record
deletion procedure DelRecord is called.
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 46
Section 8 Misc.TTT (cont.)
Function REPLICATE
Purpose To return a string of a repeated character
Syntax Replicate(N:byte;Character:char)string80;
where N is the number of repetitions (1..80)
Character is the character to repeat
Notes 1) If N is outside the range 1..80 then a single character
string is returned.
2) The function is much faster than a For loop.
Example:
{$I Decl.TTT}
{$I Misc.TTT}
begin
Write(Replicate(80,'*'));
end;
This code fragment will write a string of 80 asterisks (*).
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 47
Section 8 Misc.TTT (cont.)
Function INT_TO_STR
Purpose To convert an integer to a string
Syntax Int_to_Str(Number:integer):string20;
where Number is the integer to be converted
Notes 1) No error checking is performed by this function
Example:
{$I Decl.TTT}
{$I Misc.TTT}
var Message : string80;
begin
Message := 'That is a total of '+Int_to_Str(Strokes)+'for 18 holes');
end;
Assuming Strokes is an integer variable, value 67, then the message
string would be 'That is a total of 67 for 18 holes'.
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 48
Section 8 Misc.TTT (cont.)
Function REAL_TO_STR
Purpose To convert a real number to a string
Syntax Real_to_Str(N:real;D:byte):string20;
where N is a real number
D is the number of decimal places
Notes 1) This function returns a string with no leading
spaces.
Example:
{$I Decl.TTT}
{$I Misc.TTT}
var Message : string80;
begin
Message := 'The answer '+Real_to_Str(Result,3)+' is correct');
end;
Assuming Result is a real variable of value 367.8000000 then the
message string would be 'The answer 367.800 is correct'.
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 49
Section 8 Misc.TTT (cont.)
Function STR_TO_INT
Purpose To convert a string to an integer
Syntax Str_to_Int(Str:string80):integer;
where Str is the string to be converted
Notes 1) If the string is not a valid format then a zero is
returned.
Example:
{$I Decl.TTT}
{$I Misc.TTT}
var result : integer;
Const A = '23';B ='16';
begin
Result := Str_to_Int(A) + Str_to_Int(B);
end;
The integer variable Result would be assigned the value 39.
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 50
Section 8 Misc.TTT (cont.)
Function PRINTER_READY
Purpose To determine if the printer is connected on-line
Syntax Printer_Ready:boolean;
Notes 1) This function is most useful, when you want to bullet
proof a printer option and mnake sure that a printer is
attached and on-line before trying to route any reports
to it.
Example:
{$I Decl.TTT}
{$I Misc.TTT}
begin
If Printer_Ready then PrintScreen;
end;
This code fragment checks to see if the printer is on-line and, if it
is, a dump of the screen is printed.
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 51
Section 8 Misc.TTT (cont.)
Function TIME
Purpose To return the system time formatted nicely
Syntax Time:string20;
Notes 1) The format of the returned string is hour:min:sec a.m.
or hour:min:sec p.m. .
Example:
{$I Decl.TTT}
{$I Misc.TTT}
begin
ClrScr;
Write(Time);
end;
The above code fragment will clear the screen and print the time in
the top left corner.
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 52
Section 8 Misc.TTT (cont.)
Function DATE
Purpose To return the system date nicely formatted
Syntax Date:string30;
Notes 1) The format of the returned string is the day followed
by the month, day of month and year e.g.
Wednesday October 1, 1986
Example:
{$I Decl.TTT}
{$I Misc.TTT}
begin
ClrScr;
Write(date);
end;
The above code fragment would clear the screen and write the date in
the top left corner.
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 53
Section 8 Misc.TTT (cont.)
Function MEMAVAIL_IN_BYTES
Purpose To return the total heap space available
Syntax MemAvail_in_Bytes:real;
Notes 1) This function is used in the heap management procedures
and returns how much heap space is available. It should
be called prior to a New(variable) statement to ensure
there is enough room for the variable on the Heap.
Example:
{$I Decl.TTT}
{$I Misc.TTT}
type
RecPtr = ^Rec;
Rec = record
Value : real;
Monster : Array[1..Maxavail] of integer;
end;
var
Heapvar : RecPtr;
begin
If MemAvail_in_Bytes > Sizeof(Heapvar^) then New(Heapvar);
end;
This code segment checks to see if there is enough heap space
available to allocate the variable. If there is, the space is
allocated with the New statement.
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 54
Index
A Full List of Technojocks Procedures and Functions
sorted by page number, by TTT file, & alphabetically
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 55
In Page Number Order
Proc/Func Filename Page
Box Fastwrit.TTT ............... 9
Horizline Fastwrit.TTT ............... 10
Vertline Fastwrit.TTT ............... 11
WriteAT Fastwrit.TTT ............... 12
ClearText Fastwrit.TTT ............... 13
WriteCenter Fastwrit.TTT ............... 14
WriteBetween Fastwrit.TTT ............... 15
WriteVert Fastwrit.TTT ............... 16
TempMessage Fastwrit.TTT ............... 17
FindCursor Fastwrit.TTT ............... 18
PosCursor Fastwrit.TTT ............... 19
SizeCursor Fastwrit.TTT ............... 20
OffCursor Fastwrit.TTT ............... 21
OnCursor Fastwrit.TTT ............... 22
VideoOff Fastwrit.TTT ............... 23
VideoOn Fastwrit.TTT ............... 24
SaveScreen Window.TTT ................. 26
RestoreScreen Window.TTT ................. 27
DisposeScreen Window.TTT ................. 28
MkWin Window.TTT ................. 29
RmWin Window.TTT ................. 30
DisplayMenu Menu.TTT ................... 31
IO_Setfields IO.TTT ..................... 38
IO_DefineStr IO.TTT ..................... 38
IO_ResetFields IO.TTT ..................... 39
IO_AllowEsc IO.TTT ..................... 39
IO_Edit IO.TTT ..................... 39
IO_SoundBeeper IO.TTT ..................... 39
IO_DisplayFields IO.TTT ..................... 40
IO_SetColors IO.TTT ..................... 40
IO_HelpProc IO.TTT ..................... 40
IO_DefineMsg IO.TTT ..................... 40
Beep Misc.TTT ................... 43
PrintScreen Misc.TTT ................... 44
Wait_for_Keypress Misc.TTT ................... 45
FlushKeyBuffer Misc.TTT ................... 46
Replicate Misc.TTT ................... 47
Int_to_Str Misc.TTT ................... 48
Real_to_Str Misc.TTT ................... 49
Str_to_Int Misc.TTT ................... 50
Printer_Ready Misc.TTT ................... 51
Time Misc.TTT ................... 52
Date Misc.TTT ................... 53
MemAvail_in_Bytes Misc.TTT ................... 54
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 56
By File Alphabetically
Proc/Func Filename Page
Box Fastwrit.TTT ............... 9
ClearText Fastwrit.TTT ............... 13
FindCursor Fastwrit.TTT ............... 18
Horizline Fastwrit.TTT ............... 10
OffCursor Fastwrit.TTT ............... 21
OnCursor Fastwrit.TTT ............... 22
PosCursor Fastwrit.TTT ............... 19
SizeCursor Fastwrit.TTT ............... 20
TempMessage Fastwrit.TTT ............... 17
Vertline Fastwrit.TTT ............... 11
VideoOff Fastwrit.TTT ............... 23
VideoOn Fastwrit.TTT ............... 24
WriteAT Fastwrit.TTT ............... 12
WriteBetween Fastwrit.TTT ............... 15
WriteCenter Fastwrit.TTT ............... 14
WriteVert Fastwrit.TTT ............... 16
IO_AllowEsc IO.TTT ..................... 39
IO_DefineMsg IO.TTT ..................... 40
IO_DefineStr IO.TTT ..................... 38
IO_DisplayFields IO.TTT ..................... 40
IO_Edit IO.TTT ..................... 39
IO_HelpProc IO.TTT ..................... 40
IO_ResetFields IO.TTT ..................... 39
IO_SetColors IO.TTT ..................... 40
IO_Setfields IO.TTT ..................... 38
IO_SoundBeeper IO.TTT ..................... 39
DisplayMenu Menu.TTT ................... 31
Beep Misc.TTT ................... 43
Date Misc.TTT ................... 53
FlushKeyBuffer Misc.TTT ................... 46
Int_to_Str Misc.TTT ................... 48
MemAvail_in_Bytes Misc.TTT ................... 54
Printer_Ready Misc.TTT ................... 51
PrintScreen Misc.TTT ................... 44
Real_to_Str Misc.TTT ................... 49
Replicate Misc.TTT ................... 47
Str_to_Int Misc.TTT ................... 50
Time Misc.TTT ................... 52
Wait_for_Keypress Misc.TTT ................... 45
DisposeScreen Window.TTT ................. 28
MkWin Window.TTT ................. 29
RestoreScreen Window.TTT ................. 27
RmWin Window.TTT ................. 30
SaveScreen Window.TTT ................. 26
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 57
By Proc/Func Alphabetically
Proc/Func Filename Page
Beep Misc.TTT ................... 43
Box Fastwrit.TTT ............... 9
ClearText Fastwrit.TTT ............... 13
Date Misc.TTT ................... 53
DisplayMenu Menu.TTT ................... 31
DisposeScreen Window.TTT ................. 28
FindCursor Fastwrit.TTT ............... 18
FlushKeyBuffer Misc.TTT ................... 46
Horizline Fastwrit.TTT ............... 10
Int_to_Str Misc.TTT ................... 48
IO_AllowEsc IO.TTT ..................... 39
IO_DefineMsg IO.TTT ..................... 40
IO_DefineStr IO.TTT ..................... 38
IO_DisplayFields IO.TTT ..................... 40
IO_Edit IO.TTT ..................... 39
IO_HelpProc IO.TTT ..................... 40
IO_ResetFields IO.TTT ..................... 39
IO_SetColors IO.TTT ..................... 40
IO_Setfields IO.TTT ..................... 38
IO_SoundBeeper IO.TTT ..................... 39
MemAvail_in_Bytes Misc.TTT ................... 54
MkWin Window.TTT ................. 29
OffCursor Fastwrit.TTT ............... 21
OnCursor Fastwrit.TTT ............... 22
PosCursor Fastwrit.TTT ............... 19
Printer_Ready Misc.TTT ................... 51
PrintScreen Misc.TTT ................... 44
Real_to_Str Misc.TTT ................... 49
Replicate Misc.TTT ................... 47
RestoreScreen Window.TTT ................. 27
RmWin Window.TTT ................. 30
SaveScreen Window.TTT ................. 26
SizeCursor Fastwrit.TTT ............... 20
Str_to_Int Misc.TTT ................... 50
TempMessage Fastwrit.TTT ............... 17
Time Misc.TTT ................... 52
Vertline Fastwrit.TTT ............... 11
VideoOff Fastwrit.TTT ............... 23
VideoOn Fastwrit.TTT ............... 24
Wait_for_Keypress Misc.TTT ................... 45
WriteAT Fastwrit.TTT ............... 12
WriteBetween Fastwrit.TTT ............... 15
WriteCenter Fastwrit.TTT ............... 14
WriteVert Fastwrit.TTT ............... 16
Technojocks Turbo Toolkit v3.0 Oct 1, 1986 Page 58